
    %Stockname = ['AAA';'VND';'KLS';'CTB';'PVX';'PVG';'PVL';'THV';'DAC';'PGS'];
    %Indexname = 'HNXINDEX';
    %Stockname = ['HAG'; 'SSI';'MBB';'PVF'; 'EIB'; 'BVH';'VCB';'CTG';'STB';'HCM' ];
    Stockname = ['SSI'];
    [k l] = size(Stockname);
    Indexname = 'VNINDEX';%'MBB';
    V0 = 1;
    weights = [0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1;0.1];


    %get List of Stock 's name and Index 's name
    Listname = insertRow(Stockname,Indexname);
    [Name Date Price] = getPortfolio(Listname);

    [n m] = size(Price);
    pStock = Price(:,1:m-1);
    pIndex = Price(:,m);
    
    %get return of Stocks and Index
    rStock = getReturn(Price(:,1:end-1));
    rIndex = getReturn(Price(:,end));
    
    for i=1:k
    olsbeta(i) = BetaOLS(rStock(:,i),rIndex);
    
    bayesbeta(i) = BetaBayes(rStock(:,i),rIndex, 'HOSE','VNINDEX');
    %bayesbeta = BetaBayes(rStock,rIndex, 'HNX','HNXINDEX')
    
    medrobustbeta(i) = BetaRobustMed(rStock(:,i),rIndex);
    
    trimrobustbeta(i) = BetaRobustTrim(rStock(:,i),rIndex);
    
    weightrobustbeta(i) = BetaRobustWeight(rStock(:,i),rIndex,'andrews');
    
    shrinkagebeta(i) = BetaShrinkage(rStock(:,i),rIndex);
    
    smoothingbeta = BetaSmoothing(rStock(:,i), rIndex, 0.97);
    
    kalmanfilterbeta = BetaKalman(rStock(:,i), rIndex, 1);
    
    %kalmanfilterbeta = BetaKalman(rStock(:,i), rIndex, 2);
    
    tobitmodelbeta(i) = BetaTobit(rStock(:,i), rIndex, 0.05);
    
    truncatedbeta(i) = BetaTruncated(rStock(:,i), rIndex, 0.05);
    
    gmmbeta(i) = BetaGMM(pStock(:,i),pIndex,0.05,-0.05);
    
    %ME
    olsme(i) = ME(rStock,rIndex,olsbeta(i))
    bayesme(i) = ME(rStock,rIndex,olsbeta(i))    
    medme(i) = ME(rStock,rIndex,medrobustbeta(i))    
    trimme(i) = ME(rStock,rIndex,trimrobustbeta(i))    
    weightme(i) = ME(rStock,rIndex,weightrobustbeta(i))    
    shirnkageme(i) = ME(rStock,rIndex,shrinkagebeta(i))    
    smoothingtme(i) = ME(rStock,rIndex,smoothingbeta)    
    kalmanme(i) = ME(rStock,rIndex,kalmanfilterbeta)    
    tobitme(i) = ME(rStock,rIndex,tobitmodelbeta(i))    
    trunme(i) = ME(rStock,rIndex,truncatedbeta(i))    
    gmmme(i) = ME(rStock,rIndex,gmmbeta(i))
    
    %MSE
    olsmse(i) = MSE(rStock,rIndex,olsbeta(i))
    bayesmse(i) = MSE(rStock,rIndex,olsbeta(i))    
    medmse(i) = MSE(rStock,rIndex,medrobustbeta(i))    
    trimmse(i) = MSE(rStock,rIndex,trimrobustbeta(i))    
    weightmse(i) = MSE(rStock,rIndex,weightrobustbeta(i))    
    shirnkagemse(i) = MSE(rStock,rIndex,shrinkagebeta(i))    
    smoothingtmse(i) = MSE(rStock,rIndex,smoothingbeta)    
    kalmanmse(i) = MSE(rStock,rIndex,kalmanfilterbeta)    
    tobitmse(i) = MSE(rStock,rIndex,tobitmodelbeta(i))    
    trunmse(i) = MSE(rStock,rIndex,truncatedbeta(i))    
    gmmmse(i) = MSE(rStock,rIndex,gmmbeta(i))

    %MAD
    olsmad(i) = MAD(rStock,rIndex,olsbeta(i))
    bayesmad(i) = MAD(rStock,rIndex,olsbeta(i))    
    medmad(i) = MAD(rStock,rIndex,medrobustbeta(i))    
    trimmad(i) = MAD(rStock,rIndex,trimrobustbeta(i))    
    weightmad(i) = MAD(rStock,rIndex,weightrobustbeta(i))    
    shirnkagemad(i) = MAD(rStock,rIndex,shrinkagebeta(i))    
    smoothingtmad(i) = MAD(rStock,rIndex,smoothingbeta)    
    kalmanmad(i) = MAD(rStock,rIndex,kalmanfilterbeta)    
    tobitmad(i) = MAD(rStock,rIndex,tobitmodelbeta(i))    
    trunmad(i) = MAD(rStock,rIndex,truncatedbeta(i))    
    gmmmad(i) = MAD(rStock,rIndex,gmmbeta(i))
    
    %R^2
    olsrsquare(i) = Rsquare(rStock,rIndex,olsbeta(i))
    bayesrsquare(i) = Rsquare(rStock,rIndex,olsbeta(i))    
    medrsquare(i) = Rsquare(rStock,rIndex,medrobustbeta(i))    
    trimrsquare(i) = Rsquare(rStock,rIndex,trimrobustbeta(i))    
    weightrsquare(i) = Rsquare(rStock,rIndex,weightrobustbeta(i))    
    shirnkagersquare(i) = Rsquare(rStock,rIndex,shrinkagebeta(i))    
    smoothingtrsquare(i) = Rsquare(rStock,rIndex,smoothingbeta)    
    kalmanrsquare(i) = Rsquare(rStock,rIndex,kalmanfilterbeta)    
    tobitrsquare(i) = Rsquare(rStock,rIndex,tobitmodelbeta(i))    
    trunrsquare(i) = Rsquare(rStock,rIndex,truncatedbeta(i))    
    gmmrsquare(i) = Rsquare(rStock,rIndex,gmmbeta(i))
    
    end
    
%     figure('name','ols');
%     plot(olsbeta);
%     figure('name','bayesbeta');
%     plot(bayesbeta);
%     figure('name','med');
%     plot(medrobustbeta);
%     figure('name','trim');
%     plot(trimrobustbeta);
%     figure('name','weight');
%     plot(weightrobustbeta);
%     figure('name','shrinkage');
%     plot(shrinkage);
%     figure('name','tobit');
%     plot(tobitmodelbeta);
%     figure('name','trun');
%     plot(truncatedbeta);
%     figure('name','gmm');
%     plot(gmmbeta);
    
    
    %figure('name','AAA');
    %hold on;
    %plot(olsbeta);
    %plot(smoothingbeta,'r');
    %plot(kalmanfilterbeta,'g');

